from launch import LaunchDescription
import launch_ros.actions
import os
from ament_index_python.packages import get_package_share_directory


def generate_launch_description():
    config = os.path.join(get_package_share_directory('perception'), 'config',
                          'launch.yaml')
    cell_config = os.path.join(get_package_share_directory('perception'),
                               'config', 'cell.json')

    obj_config = os.path.join(get_package_share_directory('perception'),
                              'config', 'objs.json')

    preprocess_config = os.path.join(get_package_share_directory('perception'),
                                     'config', 'preprocess.json')
    # preprocess_config =  os.path.join(
    # get_package_share_directory('perception'),
    # 'config',
    # 'patchwork++/params.yaml'
    # )
    config_file = {
        "cell_config": cell_config,
        "obj_config": obj_config,
        "preprocess_config": preprocess_config
    }
    lidar_node_params = [config,config_file]
    print(config)
    return LaunchDescription([
        launch_ros.actions.Node(namespace="",
                                package='perception',
                                executable='perception',
                                output='screen',
                                respawn="true",
                                parameters=lidar_node_params,prefix='gdb -ex run --args')
    ])